<div class="fsh-pop">
    <div id="add_form" class="layui-form">
         <input type="hidden" name="user_id" id="user_id" value="<%=user_id%>"/>
         <input type="hidden"  id="roleId" value="<%=role_id%>"/>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" readonly="readonly" class="layui-input" value="<%=username%>">
            </div>
        </div>
        
         <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>分配角色</label>
            <div class="layui-input-block">
              <select id="role_id" lay-filter="parent" name="role_id" >
                
              </select>
    </div>
  </div>
    </div>
</div>
<script type="text/javascript">
        var defaultSelect = $("#roleId").val();
        layui.use(['form'], function () {
        var form = layui.form;
          $.ajax({ 
            url:context+'/api/sysrole/list', 
            dataType:'json', 
            type:'get',
             success:function(data){    

                if(data!=undefined&&data!=null&&data!=""){
                var list = data.data;
                var html="<option value=''>请选择角色</option>";
                    for(var i=0;i<list.length;i++){                      
                            html+="<option value="+list[i]["role_id"]+">"+list[i]["roleName"]+"</option>";
                                        
                     }
                       $("#role_id").append(html);
                       $("#role_id").val(defaultSelect);
                       form.render("select");
                }                                                                                                                                                                      
            
               
            }
            });
       
        });


</script>